home *** CD-ROM | disk | FTP | other *** search
- -- card: 4883 from stack: in.3r
- -- bmap block id: 0
- -- flags: 4000
- -- background id: 2202
- -- name: LastPathComponent
- ----- HyperTalk script -----
- function LastPathComponent name
- repeat with i = the length of name down to 1
- if character i of name is ":" then exit repeat
- end repeat
- if i is 1 then
- if first character of name is ":" then
- put 2 into i
- end if
- else
- add 1 to i -- skip the colon
- end if
- put empty into lastpath
- repeat with j = i to the length of name
- put character j of name after lastpath
- end repeat
- return lastpath
- end LastPathComponent
-
-
- -- part contents for background part 2
- ----- text -----
- --
- -- LastPathComponent -- given a file pathname, returns the last
- -- component i.e. whatever comes after the last colon, if anything.
- -- From Dewi Williams
- --
- function LastPathComponent name
- -- scan backwards for the last colon.
- repeat with i = the length of name down to 1
- if character i of name is ":" then exit repeat
- end repeat
-
- if i is 1 then
- -- Name was of the form ":thing" or "thing". Check for leading
- -- colon, and adjust if necessary. Done for generality.
- if first character of name is ":" then
- put 2 into i
- end if
- else
- add 1 to i -- skip the colon
- end if
-
- -- Name was of the form "Thing:otherthing". Return "otherThing".
- put empty into lastpath
- repeat with j = i to the length of name
- put character j of name after lastpath
- end repeat
- return lastpath
- end LastPathComponent
-
- -- part contents for background part 3
- ----- text -----
- LastPathComponent
-
- -- part contents for background part 10
- ----- text -----
- 1
-
- -- part contents for background part 19
- ----- text -----
- Functions